// This file is part of OpenTSDB.
// Copyright (C) 2017 TeleDB Development Group.
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version.  This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
// General Public License for more details.  You should have received a copy
// of the GNU Lesser General Public License along with this program.  If not,
// see <http://www.gnu.org/licenses/>.
package net.opentsdb.tsd.service;

import net.opentsdb.core.TSDB;
import net.opentsdb.tsd.HttpQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 矫正计数器
 */
public class CorrectCountService extends RpcServiceImpl{

    private static final Logger LOG = LoggerFactory.getLogger(CorrectCountService.class);

    public CorrectCountService(TSDB tsdb, HttpQuery query) {
        super(tsdb, query);
    }

    @Override
    public void doGet() {
        doPost();
    }

    @Override
    public void doPost() {
        Long count;
        try {
            count = tsdb.getHbaseWrapper().metaUtils.inCorrectCount();
            putResponse(true, String.valueOf(count));
            LOG.info("Success incorrect tsuid count size: "+count);
        } catch (Exception e) {
            LOG.error("incorrect hbase size error :"+e.getMessage());
            putErrorResponse(false, "delete metric error:"+e.getMessage());
        }
    }

    @Override
    public void checks() {

    }
}
